<!DOCTYPE html>
<html>
    
    <head>
       <meta charset="UTF-8">
        {include="style"}

		{include="edit"}
    </head>
    
    <body>
	 <div class="x-nav">
            <span class="layui-breadcrumb">
              <a><cite>{fun JZLANG('首页')}</cite></a>
              <a><cite>{$molds['name']}{fun JZLANG('管理')}</cite></a>
             
			 <a><cite>{fun JZLANG('新增')}{$molds['name']}</cite></a>
            </span>
            
            <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"  href="javascript:location.replace(location.href);" title="{fun JZLANG('刷新')}"><i class="iconfont" style="line-height:30px">&#xe6aa;</i></a>
        </div>
        <div class="x-body">
            <form class="layui-form layui-form-pane" lay-filter="jizhiform">
			<input type="hidden" name="go" value="1" />
			
			<div class="layui-tab">
			  <ul class="layui-tab-title">
				<li class="layui-this">{fun JZLANG('基础')}</li>
				<li>{fun JZLANG('扩展')}</li>
				<li>{fun JZLANG('设置')}</li>
				
			  </ul>
			  <div class="layui-tab-content">
				<div class="layui-tab-item layui-show">

				{if($molds['isclasstype']==1)}
				<div class="layui-form-item">
                    <label for="tid" class="layui-form-label">
                        <span class="x-red">*</span>{fun JZLANG('栏目')}
                    </label>
                    <div class="layui-input-inline">
						<select name="tid" lay-search="" {if($molds['ismust']==1)} lay-verify="required" {/if} lay-filter="tid" id="tid" >
						{if($molds['ismust']==1)}
						<option value="">{fun JZLANG('选择栏目')}</option>
						{else}
						<option value="0">{fun JZLANG('不限栏目')}</option>
						{/if}
					   {foreach $classtypes as $v}
					   {if($v['molds']=='article')}
					   {if($admin['classcontrol']==0 || $admin['isadmin']==1 || strpos($tids,','.$v['id'].',')!==false || $molds['iscontrol']==0)}
					   <option {if($tid==$v['id'])}selected{/if} value="{$v['id']}">{fun str_repeat('--', $v['level'])}{$v['classname']}</option>
					   {/if}
					   {/if}
					   {/foreach}
					  
					   </select>
					</div>
					<div class="layui-input-inline">
						<span class="x-red">{fun JZLANG('填写内容时，请先选择栏目，否则切换栏目后，数据会丢失！')}</span>
                    </div>
					<div class="layui-input-inline">
						<button type="button" id="resetdata" class="layui-btn layui-btn-sm">{fun JZLANG('恢复数据')}</button>
                    </div>
                </div>
				{else}
				<input type="hidden" name="tid" value="0" />
				{/if}
				
				<span id="content_fields"></span>
	
				</div>
				<div class="layui-tab-item">
				<span id="ext_fields"></span>
				
				</div>
				<div class="layui-tab-item">
				<blockquote class="layui-elem-quote">{fun JZLANG('此规则配置仅在不填留空的情况下才会触发')}</blockquote>
					  <div class="layui-form-item">
						<label class="layui-form-label">{fun JZLANG('SEO标题')}</label>
						<div class="layui-input-inline">
						  <select name="config_seotitle" >
							<option {if($configdata['seotitle']==1)}selected{/if} value="1">{fun JZLANG('等于内容标题')}</option>
							<option {if($configdata['seotitle']==2)}selected{/if} value="2">{fun JZLANG('不填则留空')}</option>
						  </select>
						</div>
					  </div>
					  <div class="layui-form-item">
						<label class="layui-form-label">{fun JZLANG('缩略图规则')}</label>
						<div class="layui-input-inline">
						  <select name="config_litpic" >
							<option {if($configdata['litpic']==1)}selected{/if} value="1">{fun JZLANG('自动获取内容第一张图片')}</option>
							<option {if($configdata['litpic']==2)}selected{/if} value="2">{fun JZLANG('不自动获取')}</option>
						  </select>
						</div>
					  </div>
					  <div class="layui-form-item">
						<label class="layui-form-label">{fun JZLANG('简介规则')}</label>
						<div class="layui-input-inline">
						  <select name="config_description" >
							<option {if($configdata['description']==1)}selected{/if} value="1">{fun JZLANG('自动获取内容前200字符')}</option>
							<option {if($configdata['description']==2)}selected{/if} value="2">{fun JZLANG('不自动获取')}</option>
						  </select>
						</div>
					  </div>
					  <div class="layui-form-item">
						<label class="layui-form-label">{fun JZLANG('TAG规则')}</label>
						<div class="layui-input-inline">
						  <select name="config_tags" >
							<option {if($configdata['tags']==1)}selected{/if} value="1">{fun JZLANG('同步关键词')}</option>
							<option {if($configdata['tags']==2)}selected{/if} value="2">{fun JZLANG('不同步关键词')}</option>
						  </select>
						</div>
					  </div>
					  <div class="layui-form-item  layui-form-text">
						<label class="layui-form-label">{fun JZLANG('敏感词过滤字段')} <span class="x-red">{fun JZLANG('需要过滤敏感词在系统配置中进行设置')}</span></label>
						<div class="layui-input-block">
						  <textarea placeholder="{fun JZLANG('请输入需要过滤的字段')}" name="config_filter" class="layui-textarea">{$configdata['filter']}</textarea>
						</div>
					  </div>
					  
				
				</div>
				
				
			  </div>
			</div>
						

                <div class="layui-form-item" id="jizhitj" style="text-align:center;">
                    
                     <button  class="layui-btn" lay-filter="save" lay-submit="">
                        {fun JZLANG('保存')}
                    </button>
                </div>
            </form>
        </div>
		<br/>
		<br/>
		<br/>
		<br/>
		<br/>
		<br/>
		<br/>
		<br/>
		<br/>
      
        <script>
		{include="fields"}
			$(function() {
			 
			  get_fields({$tid});
			  get_fields_ext({$tid});

			})
			
            layui.use(['laydate','form','layer','upload'], function(){
                $ = layui.jquery;
              var form = layui.form
              ,layer = layui.layer;
			  laydate = layui.laydate;
			  var upload = layui.upload;
			  
			
			    //监听提交
              form.on('submit(save)', function(data){
				if($("#tids").length>0){
					var tids_str = tids_obj.getValue('valueStr');
					if(tids_str!=''){
					data.field.tids = ','+tids_str+',';
					}
					
				}
				$.post("{fun U('addarticle')}",data.field,function(r){
					localStorage.setItem('cachedata', '');
					var r = JSON.parse(r);
					if(r.code==0){
						layer.confirm(r.msg, {
						  btn: ['{fun JZLANG('返回')}','{fun JZLANG('确定')}'] //按钮
						}, function(){
						   
						   {if($webconf['admintpl']=='tpl')}
						   window.location.href="{fun U('Article/articlelist')}";
						  {else}
						   parent.location.reload();
						   parent.layer.close(index);
						   
						  {/if}
						   
						}, function(){
						   window.location.href=r.url;
						});
					
						
					}else{
						layer.alert(r.msg, {icon: 5});
					}
				});
				
               
                return false;
              });
            form.on('select(tid)', function(data){
			  var alldata = form.val("jizhiform");
			  localStorage.setItem('cachedata', JSON.stringify(alldata));
			  get_fields(data.value);
			  get_fields_ext(data.value);
			  
			});
			
			$("#resetdata").click(function(){
				var alldata = localStorage.getItem('cachedata');
				if(alldata!=''){
					form.val("jizhiform",JSON.parse(alldata));
				}
			})
			
              
              
            });
        </script>
      
    </body>

</html>